package com.api.shopapi.service.impl;


import com.api.shopapi.entity.ElderlyClass;
import com.api.shopapi.entity.dto.ElderlyClassDTO;
import com.api.shopapi.mapper.ElderlyClassMapper;
import com.api.shopapi.service.ElderlyClassService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author maochuan
 */
@Service("ElderlyClassServiceImplOne")
public class ElderlyClassServiceImpl implements ElderlyClassService {
    @Autowired
    private ElderlyClassMapper elderlyClassMapper;
    @Override
    public int insert(ElderlyClass elderlyClass) {
        return elderlyClassMapper.insert(elderlyClass);
    }

    @Override
    public int update(ElderlyClass elderlyClass) {
        return elderlyClassMapper.update(elderlyClass);
    }

    @Override
    public int delete(String elderlyClassCode) {
        return elderlyClassMapper.delete(elderlyClassCode);
    }

    @Override
    public List<ElderlyClass> getList(String governmentCode) {
        return elderlyClassMapper.getList(governmentCode);
    }

    @Override
    public ElderlyClass getByElderlyClassCode(String elderlyClassCode) {
        return elderlyClassMapper.getByElderlyClassCode(elderlyClassCode);
    }

    @Override
    public ElderlyClass getByNameAndGovernmentCode(String name, String governmentCode) {
        return elderlyClassMapper.getByNameAndGovernmentCode(name,governmentCode);
    }


    @Override
    public
    ElderlyClass getByValueAndGovernmentCode(int value,String governmentCode){
        return elderlyClassMapper.getByValueAndGovernmentCode(value,governmentCode);
    }

    @Override
    public PageInfo<ElderlyClass> getPageList(int pageIndex, int pageSize, String name, String governmentCode) {
        PageHelper.startPage(pageIndex, pageSize);
        List<ElderlyClass> elderlyClasses = elderlyClassMapper.getPageList(name,governmentCode);
        PageInfo<ElderlyClass> pageInfo = new PageInfo<ElderlyClass>(elderlyClasses);
        return pageInfo;
    }

    @Override
    public ElderlyClass getByStaffCode(String staffCode) {
        return elderlyClassMapper.getByStaffCode(staffCode);
    }

    @Override
    public ElderlyClass getByValue(int value, String governmentCode) {
        return elderlyClassMapper.getByValue(value,governmentCode);
    }

    @Override
    public ElderlyClass getByName(String name,String governmentCode) {
        return elderlyClassMapper.getByName(name,governmentCode);
    }

    //列表
    @Override
    public PageInfo<ElderlyClassDTO> getListPage(int pageIndex, int pageSize) {
        PageHelper.startPage(pageIndex,pageSize);
        List<ElderlyClassDTO> elderlyClassList =elderlyClassMapper.getListPage();
        return new PageInfo<>(elderlyClassList);
    }
}
